//
//  DoctorViewControllerTableViewController.m
//  DrProcessTable
//
//  Created by 白岩凇 on 2016/10/5.
//  Copyright © 2016年 白岩凇. All rights reserved.
//

#import "DoctorViewControllerTableViewController.h"
#import "DktCellModel.h"
#import "DoctorCell.h"
#import "confirmViewController.h"
#import "MJExtension.h"

#define navigationTitle @"选择医生"
@interface DoctorViewControllerTableViewController ()
//模型数组

@end

@implementation DoctorViewControllerTableViewController

- (NSMutableArray *)models{
    NSMutableArray* modelsArray=[NSMutableArray array];
    //字典数组转模型数组 mjExtension框架
    modelsArray=[DktCellModel mj_objectArrayWithKeyValuesArray:_models];
    // modelsArray=[HsptCellModel mj_objectArrayWithKeyValuesArray:HsptInfoArray];
    _models=modelsArray;
    
    //        NSLog(@"--------------\n %@ \n-------------------",_models);
    //}
    return _models;}

- (void)viewDidLoad {
    [super viewDidLoad];
   // self.navigationItem.title=navigationTitle;
    self.tableView.separatorInset=UIEdgeInsetsZero;
}


#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.models.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DoctorCell* cell=[DoctorCell cellWithTableView:tableView];
    cell.model=self.models[indexPath.row];
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    DktCellModel* need=self.models[indexPath.row];
    CGFloat needH=need.h;
    return needH;
}

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath  {
    return 200;
}

#warning 进入最终确认
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    DoctorCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    
    confirmViewController *need= [[confirmViewController alloc]initWithNibName:@"confirmViewController" bundle:[NSBundle mainBundle]];
    //对确认界面的remainN赋值
    DktCellModel* model=self.models[indexPath.row];
    need.remainN=model.DoctorStatus;
    need.title = cell.model.DoctorName;
    need.model = cell.model;
    //设置返回按钮样式
    self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    [self.navigationController pushViewController:need animated:YES];
    
}
@end
